package com.woniuxy.exam.config;

import com.woniuxy.exam.intercepters.PermissionIntercepter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WEbMvcConfig  implements WebMvcConfigurer {

    @Autowired
    PermissionIntercepter permissionIntercepter ;

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("login.html").setViewName("login");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截所有的请求   包括静态资源
        registry.addInterceptor(permissionIntercepter)
                .addPathPatterns("/**")
                .excludePathPatterns("/asserts/**")
                .excludePathPatterns("/login.html","/manager/login");
    }
}
